<?php

namespace App\Http\Controllers\Api\v1;

use App\Http\Resources\CustomerResource;
use App\Http\Resources\SalesmanResource;
use App\Models\Customer;
use App\Models\Problem;
use App\Models\Order;
use App\Http\Requests\Api\v1\ProblemRequest;
use App\Models\Salesman;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Tymon\JWTAuth\Facades\JWTAuth;

/**
 * 问题
 * @package App\Http\Controllers\Api\v1
 */
class SalesmanController extends Controller
{
    public function getSalesaman(Request $request)
    {
        $user = auth('api')->user();
        $salesman = app(Salesman::class)->userSalesman($user);
        if (!$salesman) {
            $this->errorResponse(Response::HTTP_OK, trans('error.' . 10023), 10023);
        }
        return $this->success($salesman ? new SalesmanResource($salesman) : $salesman);
    }


}
